package com.example.carapi.service.implement;

import com.example.carapi.bean.CarBrand;
import com.example.carapi.mapper.CarBrandMapper;
import com.example.carapi.service.CarBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CarBrandServiceImplement implements CarBrandService {
    @Autowired
    private CarBrandMapper carBrandMapper;

    @Override
    public CarBrand getCarBrandById(Long id) {
        return carBrandMapper.getOne(id);
    }

    @Override
    public List<CarBrand> getCarBrands() {
        return carBrandMapper.getAll();
    }

    @Override
    public void addCarBrand(CarBrand carBrand) {
        carBrandMapper.insert(carBrand);
    }

    @Override
    public void updateCarBrand(CarBrand carBrand) {
        carBrandMapper.update(carBrand);
    }

    @Override
    public void deleteCarBrandById(Long id) {
        carBrandMapper.delete(id);
    }
}
